

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>federatedml.util.parameter_util &mdash; FATE 1.0 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script type="text/javascript" src="../../../_static/jquery.js"></script>
        <script type="text/javascript" src="../../../_static/underscore.js"></script>
        <script type="text/javascript" src="../../../_static/doctools.js"></script>
        <script type="text/javascript" src="../../../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html" class="icon icon-home"> FATE
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"></div>
            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">FATE</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../../index.html">Module code</a> &raquo;</li>
        
      <li>federatedml.util.parameter_util</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for federatedml.util.parameter_util</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1">#  Copyright 2019 The FATE Authors. All Rights Reserved.</span>
<span class="c1">#</span>
<span class="c1">#  Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span>
<span class="c1">#  you may not use this file except in compliance with the License.</span>
<span class="c1">#  You may obtain a copy of the License at</span>
<span class="c1">#</span>
<span class="c1">#      http://www.apache.org/licenses/LICENSE-2.0</span>
<span class="c1">#</span>
<span class="c1">#  Unless required by applicable law or agreed to in writing, software</span>
<span class="c1">#  distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span>
<span class="c1">#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<span class="c1">#  See the License for the specific language governing permissions and</span>
<span class="c1">#  limitations under the License.</span>
<span class="c1">#</span>

<span class="kn">import</span> <span class="nn">builtins</span>
<span class="kn">import</span> <span class="nn">importlib</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">copy</span>


<div class="viewcode-block" id="ParameterOverride"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.parameter_util.ParameterOverride">[docs]</a><span class="k">class</span> <span class="nc">ParameterOverride</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="ParameterOverride.override_parameter"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.parameter_util.ParameterOverride.override_parameter">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">override_parameter</span><span class="p">(</span><span class="n">default_runtime_conf_prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">setting_conf_prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">submit_conf</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">module</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                           <span class="n">module_alias</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>

        <span class="n">_module_setting_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">setting_conf_prefix</span><span class="p">,</span> <span class="n">module</span> <span class="o">+</span> <span class="s2">&quot;.json&quot;</span><span class="p">)</span>
        <span class="n">_module_setting</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">_module_setting_path</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fin</span><span class="p">:</span>
            <span class="n">_module_setting</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">fin</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">_module_setting</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> is not set in setting_conf &quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">module</span><span class="p">))</span>

        <span class="n">param_class_path</span> <span class="o">=</span> <span class="n">_module_setting</span><span class="p">[</span><span class="s2">&quot;param_class&quot;</span><span class="p">]</span>
        <span class="n">param_class</span> <span class="o">=</span> <span class="n">param_class_path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;/&quot;</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
        <span class="n">param_module_path</span> <span class="o">=</span> <span class="s2">&quot;.&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">param_class_path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;/&quot;</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;.py&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span>
        <span class="n">param_module</span> <span class="o">=</span> <span class="n">importlib</span><span class="o">.</span><span class="n">import_module</span><span class="p">(</span><span class="n">param_module_path</span><span class="p">)</span>
        <span class="n">param_obj</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">param_module</span><span class="p">,</span> <span class="n">param_class</span><span class="p">)()</span>
        <span class="n">default_runtime_dict</span> <span class="o">=</span> <span class="n">ParameterOverride</span><span class="o">.</span><span class="n">change_object_to_dict</span><span class="p">(</span><span class="n">param_obj</span><span class="p">)</span> 

        <span class="n">default_runtime_conf_suf</span> <span class="o">=</span> <span class="n">_module_setting</span><span class="p">[</span><span class="s2">&quot;default_runtime_conf&quot;</span><span class="p">]</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">default_runtime_conf_prefix</span><span class="p">,</span> <span class="n">default_runtime_conf_suf</span><span class="p">),</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fin</span><span class="p">:</span>
                <span class="n">default_runtime_dict</span> <span class="o">=</span> <span class="n">ParameterOverride</span><span class="o">.</span><span class="n">merge_parameters</span><span class="p">(</span><span class="n">default_runtime_dict</span><span class="p">,</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">fin</span><span class="o">.</span><span class="n">read</span><span class="p">()),</span> <span class="n">param_obj</span><span class="p">);</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;default runtime conf should be a json file&quot;</span><span class="p">)</span>
        
        <span class="n">submit_dict</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">submit_conf</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fin</span><span class="p">:</span>
            <span class="n">submit_dict</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">fin</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">submit_dict</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;submit conf does exist or format is wrong&quot;</span><span class="p">)</span>

        <span class="n">runtime_role_parameters</span> <span class="o">=</span> <span class="p">{}</span>

        <span class="n">_support_rols</span> <span class="o">=</span> <span class="n">_module_setting</span><span class="p">[</span><span class="s2">&quot;role&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">role</span> <span class="ow">in</span> <span class="n">submit_dict</span><span class="p">[</span><span class="s2">&quot;role&quot;</span><span class="p">]:</span>
            <span class="n">_role_setting</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">for</span> <span class="n">_rolelist</span> <span class="ow">in</span> <span class="n">_support_rols</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">role</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">_rolelist</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;|&quot;</span><span class="p">):</span>
                    <span class="k">continue</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">_role_setting</span> <span class="o">=</span> <span class="n">_module_setting</span><span class="p">[</span><span class="s2">&quot;role&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">_rolelist</span><span class="p">)</span>

            <span class="k">if</span> <span class="ow">not</span> <span class="n">_role_setting</span><span class="p">:</span>
                <span class="k">continue</span>

            <span class="n">_code_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">_module_setting</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;module_path&#39;</span><span class="p">),</span> <span class="n">_role_setting</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;program&#39;</span><span class="p">))</span>
            <span class="n">partyid_list</span> <span class="o">=</span> <span class="n">submit_dict</span><span class="p">[</span><span class="s2">&quot;role&quot;</span><span class="p">][</span><span class="n">role</span><span class="p">]</span>
            <span class="n">runtime_role_parameters</span><span class="p">[</span><span class="n">role</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>

            <span class="k">for</span> <span class="n">idx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">partyid_list</span><span class="p">)):</span>
                <span class="n">runtime_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">param_class</span> <span class="p">:</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">default_runtime_dict</span><span class="p">)}</span>
                <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">submit_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                    <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;algorithm_parameters&quot;</span><span class="p">,</span> <span class="s2">&quot;role_parameters&quot;</span><span class="p">]:</span>
                        <span class="n">runtime_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>

                <span class="k">if</span> <span class="s2">&quot;algorithm_parameters&quot;</span> <span class="ow">in</span> <span class="n">submit_dict</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">module_alias</span> <span class="ow">in</span> <span class="n">submit_dict</span><span class="p">[</span><span class="s2">&quot;algorithm_parameters&quot;</span><span class="p">]:</span>
                        <span class="n">common_parameters</span> <span class="o">=</span> <span class="n">submit_dict</span><span class="p">[</span><span class="s2">&quot;algorithm_parameters&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">module_alias</span><span class="p">)</span>
                        <span class="n">merge_dict</span> <span class="o">=</span> <span class="n">ParameterOverride</span><span class="o">.</span><span class="n">merge_parameters</span><span class="p">(</span><span class="n">runtime_dict</span><span class="p">[</span><span class="n">param_class</span><span class="p">],</span> <span class="n">common_parameters</span><span class="p">,</span> <span class="n">param_obj</span><span class="p">)</span>
                        <span class="n">runtime_dict</span><span class="p">[</span><span class="n">param_class</span><span class="p">]</span> <span class="o">=</span> <span class="n">merge_dict</span>
                
                <span class="k">if</span> <span class="s2">&quot;role_parameters&quot;</span> <span class="ow">in</span> <span class="n">submit_dict</span> <span class="ow">and</span> <span class="n">role</span> <span class="ow">in</span> <span class="n">submit_dict</span><span class="p">[</span><span class="s2">&quot;role_parameters&quot;</span><span class="p">]:</span>
                    <span class="n">role_dict</span> <span class="o">=</span> <span class="n">submit_dict</span><span class="p">[</span><span class="s2">&quot;role_parameters&quot;</span><span class="p">][</span><span class="n">role</span><span class="p">]</span>
                    <span class="k">if</span> <span class="n">module_alias</span> <span class="ow">in</span> <span class="n">role_dict</span><span class="p">:</span>
                        <span class="n">role_parameters</span> <span class="o">=</span> <span class="n">role_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">module_alias</span><span class="p">)</span>
                        <span class="n">merge_dict</span> <span class="o">=</span> <span class="n">ParameterOverride</span><span class="o">.</span><span class="n">merge_parameters</span><span class="p">(</span><span class="n">runtime_dict</span><span class="p">[</span><span class="n">param_class</span><span class="p">],</span> <span class="n">role_parameters</span><span class="p">,</span> <span class="n">param_obj</span><span class="p">,</span> <span class="n">idx</span><span class="p">)</span>
                        <span class="n">runtime_dict</span><span class="p">[</span><span class="n">param_class</span><span class="p">]</span> <span class="o">=</span> <span class="n">merge_dict</span>
                
                <span class="n">runtime_dict</span><span class="p">[</span><span class="s1">&#39;local&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">submit_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;local&#39;</span><span class="p">,</span> <span class="p">{})</span>
                <span class="n">my_local</span> <span class="o">=</span> <span class="p">{</span>
                    <span class="s2">&quot;role&quot;</span><span class="p">:</span> <span class="n">role</span><span class="p">,</span> <span class="s2">&quot;party_id&quot;</span><span class="p">:</span> <span class="n">partyid_list</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span>
                <span class="p">}</span>
                <span class="n">runtime_dict</span><span class="p">[</span><span class="s1">&#39;local&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">my_local</span><span class="p">)</span>
                <span class="n">runtime_dict</span><span class="p">[</span><span class="s1">&#39;CodePath&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">_code_path</span>
                <span class="n">runtime_dict</span><span class="p">[</span><span class="s1">&#39;module&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">module</span>

                <span class="n">runtime_role_parameters</span><span class="p">[</span><span class="n">role</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">runtime_dict</span><span class="p">)</span>
        
        <span class="k">return</span> <span class="n">runtime_role_parameters</span></div>

<div class="viewcode-block" id="ParameterOverride.merge_parameters"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.parameter_util.ParameterOverride.merge_parameters">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">merge_parameters</span><span class="p">(</span><span class="n">runtime_dict</span><span class="p">,</span> <span class="n">role_parameters</span><span class="p">,</span> <span class="n">param_obj</span><span class="p">,</span> <span class="n">idx</span><span class="o">=-</span><span class="mi">1</span><span class="p">):</span>
        <span class="n">param_variables</span> <span class="o">=</span> <span class="n">param_obj</span><span class="o">.</span><span class="vm">__dict__</span>
        <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">val_list</span> <span class="ow">in</span> <span class="n">role_parameters</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">param_variables</span><span class="p">:</span>
                <span class="k">continue</span>

            <span class="n">attr</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">param_obj</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">attr</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">in</span> <span class="nb">dir</span><span class="p">(</span><span class="n">builtins</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">attr</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">idx</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">val_list</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="n">idx</span><span class="p">:</span>
                        <span class="k">continue</span>
                    <span class="n">runtime_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">val_list</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">runtime_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">val_list</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">runtime_dict</span><span class="p">:</span>
                    <span class="n">runtime_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="n">runtime_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">ParameterOverride</span><span class="o">.</span><span class="n">merge_parameters</span><span class="p">(</span><span class="n">runtime_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">),</span> <span class="n">val_list</span><span class="p">,</span> <span class="n">attr</span><span class="p">,</span> <span class="n">idx</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">runtime_dict</span></div>

<div class="viewcode-block" id="ParameterOverride.get_args_input"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.parameter_util.ParameterOverride.get_args_input">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">get_args_input</span><span class="p">(</span><span class="n">submit_conf</span><span class="p">,</span> <span class="n">module</span><span class="o">=</span><span class="s2">&quot;args&quot;</span><span class="p">):</span>
        <span class="n">submit_dict</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">submit_conf</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fin</span><span class="p">:</span>
            <span class="n">submit_dict</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">fin</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>

        <span class="k">if</span> <span class="s2">&quot;role_parameters&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">submit_dict</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">{}</span>

        <span class="n">roles</span> <span class="o">=</span> <span class="n">submit_dict</span><span class="p">[</span><span class="s2">&quot;role_parameters&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">roles</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">{}</span>

        <span class="n">args_input</span> <span class="o">=</span> <span class="p">{}</span>

        <span class="k">for</span> <span class="n">role</span> <span class="ow">in</span> <span class="n">roles</span><span class="p">:</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">submit_dict</span><span class="p">[</span><span class="s2">&quot;role_parameters&quot;</span><span class="p">][</span><span class="n">role</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">module</span><span class="p">):</span>
                <span class="k">continue</span>

            <span class="n">args_parameters</span> <span class="o">=</span> <span class="n">submit_dict</span><span class="p">[</span><span class="s2">&quot;role_parameters&quot;</span><span class="p">][</span><span class="n">role</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">module</span><span class="p">)</span>
            <span class="n">args_input</span><span class="p">[</span><span class="n">role</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
  
            <span class="k">if</span> <span class="s2">&quot;data&quot;</span> <span class="ow">in</span> <span class="n">args_parameters</span><span class="p">:</span>
                <span class="n">dataset</span> <span class="o">=</span> <span class="n">args_parameters</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;data&quot;</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">data_key</span> <span class="ow">in</span> <span class="n">dataset</span><span class="p">:</span>
                    <span class="n">datalist</span> <span class="o">=</span> <span class="n">dataset</span><span class="p">[</span><span class="n">data_key</span><span class="p">]</span>
                    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">datalist</span><span class="p">)):</span>
                        <span class="n">value</span> <span class="o">=</span> <span class="n">datalist</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
                        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args_input</span><span class="p">[</span><span class="n">role</span><span class="p">])</span> <span class="o">&lt;=</span> <span class="n">i</span><span class="p">:</span>
                            <span class="n">args_input</span><span class="p">[</span><span class="n">role</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="n">module</span><span class="p">:</span> 
                                                      <span class="p">{</span><span class="s2">&quot;data&quot;</span><span class="p">:</span> 
                                                        <span class="p">{}</span>
                                                      <span class="p">}</span>
                                                    <span class="p">})</span>

                        <span class="n">args_input</span><span class="p">[</span><span class="n">role</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">module</span><span class="p">][</span><span class="s2">&quot;data&quot;</span><span class="p">][</span><span class="n">data_key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>

        <span class="k">return</span> <span class="n">args_input</span></div>
  
<div class="viewcode-block" id="ParameterOverride.change_object_to_dict"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.parameter_util.ParameterOverride.change_object_to_dict">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">change_object_to_dict</span><span class="p">(</span><span class="n">obj</span><span class="p">):</span>
        <span class="n">ret_dict</span> <span class="o">=</span> <span class="p">{}</span>
        
        <span class="n">variable_dict</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="vm">__dict__</span>
        <span class="k">for</span> <span class="n">variable</span> <span class="ow">in</span> <span class="n">variable_dict</span><span class="p">:</span>
            <span class="n">attr</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">variable</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">attr</span> <span class="ow">and</span> <span class="nb">type</span><span class="p">(</span><span class="n">attr</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="nb">dir</span><span class="p">(</span><span class="n">builtins</span><span class="p">):</span>
                <span class="n">ret_dict</span><span class="p">[</span><span class="n">variable</span><span class="p">]</span> <span class="o">=</span> <span class="n">ParameterOverride</span><span class="o">.</span><span class="n">change_object_to_dict</span><span class="p">(</span><span class="n">attr</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">ret_dict</span><span class="p">[</span><span class="n">variable</span><span class="p">]</span> <span class="o">=</span> <span class="n">attr</span>

        <span class="k">return</span> <span class="n">ret_dict</span></div></div>
</pre></div>

           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, FATE_TEAM

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>